<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>   
<%@ taglib prefix="elfunc" uri="/WEB-INF/tlds/el-functions.tld" %>
 
	<c:set var="FileUtils" value="${fileUtil}" />
	<c:url value="bbs_modify_form.action" var="toURL">
		<c:param name="bname" value="${bname}"/>
		<c:param name="seq" value="${seq}"/>
		<c:param name="groups" value="${seq}"/>
		<c:param name="step" value="${step}"/>
		<c:param name="depth" value="${depth}"/>
		<c:param name="currentPage" value="${currentPage}"/>
		<c:param name="mode" value="u"/>
	</c:url> 
	<script type="text/javascript">
	<!--
		var f = document.writeForm;
		function del(){
			var answer = confirm("삭제 하시겠습니까?");
			if(answer){
				f.action = "bbs_delete.action";
				f.submit();
			}
		}
	
		//var comHtml;
		$(function(){
			$("#commentSubmit").click(function(){
				if( $.trim($("[name='comments']").val()) == ''){
					alert('코멘트 입력하세요 ');
					$("[name='comments']").focus();
					return false;
				}
				$.ajax({
					  url:'comment_write.action',
					  async:false,
					  type:"post",
					 // dataType:'json',
					  data: $('form').serialize(),  
					  success: function(data) {
						 /*  p = eval("(" + data + ")");
						  for(i=0;i<p.data.length;i++){
							 comHtml += "<tr>"+
											"<td width=\"92\" class=\"name\">"+p.data[i].userid+"</td>"+
											"<td width=\"465\" class=\"contents\">"+p.data[i].comments+"</td>"+
											"<td width=\"84\" class=\"date\">"+p.data[i].regdate+"</td>"+
											"<td width=\"109\" class=\"btn\">삭제</td>"+
										 "</tr>";
						  } */
						  $(".comment tbody").prepend(data);
						 // console.log(comHtml);
						  //console.log(datas[0].userid);
					    /* setTimeout(function(){
					    	document.location.reload();
					    },100); */				    
					  },
					  error:function(){
						  alert('오류발생');
					  }
				});
				/* $.get('commentInsert.action',
						{
						 userid:'asdf1234',
						 comments:$("[name='comments']").val(),	
						 seq: $("[name='seq']").val()
						},
						function(data) {
							
							alert(data)
						}
				); */
			});
			//console.log($(".comment tbody").html());
		});
		
	//-->
	</script>
	<h3>뷰</h3>
	<form method="post" name="writeForm">
	<input type="hidden" name="seq" value="${seq}"/>
	<table border="1" cellspacing="0" width="100%" class="bbs">
	<tbody>
		<tr>
			<th align="center" width="100">제목</th>
			<td>${boardVo.title}</td>
			<th align="center" width="100">글쓴이</th>
			<td>${boardVo.writer}</td>
		</tr>
		<tr>
			<th align="center" width="100">날짜</th>
			<td>${boardVo.reg_date}</td>
			<th align="center" width="100">조회수</th>
			<td>${boardVo.hit+1}</td>
		</tr>
		<tr>
			<th align="center" width="100">파일</th>
			<td colspan="3">
				<ul>
				<c:forEach items="${fileList}" var="files" varStatus="status">
					<c:url var="fileLink" value="download.action">
						<c:param name="dir">C:\work\ssol2\WebContent\upload\</c:param>
						<c:param name="fileName">${files.fileName}</c:param>
						<c:param name="fileRealName">>${ files.fileRealName }</c:param>
					</c:url>
					<li class="files"><a href="${fileLink}">${files.fileRealName}</a></li>
				</c:forEach>
				</ul>
			</td>
		</tr>
		<tr>
			<td colspan="4">
			<p class="contents">
			${boardVo.content}
			</p>
			</td>
		</tr>
	</tbody>
	<tfoot>
		<tr>
			<td align="right" colspan="4">
				<input type="button" class="button" value="수정" onclick="location.href='${toURL}'"/>
				<input type="button" class="button" value="삭제" onclick="del();"/>
				<input type="button" class="button" value="답글" onclick="location.href='bbs_reply_form.action?mode=r&bname=${boardVo.bname}&seq=${seq}&currentPage=${currentPage}'"/>
				<input type="button" class="button" value="목록"/>
			</td>
		</tr>
	</tfoot>
	</table>
	<P>
	<table border="1" cellspacing="1" width="100%" class="bbs comment">
	<thead>	${commentlist},${pagingHtml}
		<tr>
			<td colspan=3>
			<textarea name="comments" style="width:700px;height:125px;"></textarea>
			</td>
			<td>
			<input type="button" class="button" id="commentSubmit" value="코멘트" "/>
			</td>
		</tr>
	</thead>
	<tbody>	
		<tr>
			<td width="92" class="name">${commentVo.userid}</td>
			<td width="465" class="contents">${commentVo.comments}</td>
			<td width="84" class="date">01/01 09:33</td>
			<td width="109" class="btn">삭제</td>
		</tr>		
	</tbody>
	</table>
	<%-- <table>
	<thead>
		<tr>
			<th align="center" width="100">번호</th>
			<th>내용</th>
			<th align="center" width="100">글쓴이</th>
			<th align="center" width="100">날짜</th>
		</tr>
	</thead>
	<tbody>
		<!-- 반복문시작 -->
		<c:set var="sn" value="${pageStartNum}"/>
		<c:forEach var="list" items="${list}"  varStatus="status">
		<!--fmt:parseDate value="${list.reg_date}" pattern="yyyyMMdd" var="date"/-->
		<c:set var="reply" value="0"/>
		<c:set var="replyIcon" value=""/>
		<c:url value="/admin/bbs_view.action" var="toURL">
			<c:param name="bname" value="${list.bname}"/>
			<c:param name="seq" value="${list.seq}"/>
			<c:param name="currentPage" value="${currentPage}"/>
		</c:url> 
		</c:forEach>
		<!-- 반복문끝-->
	</tbody>
	</table> --%>
	</form>
	